package org.chispa.api.domain;

import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;

/**
 * @author  bgabor
 */
@JsonSerialize(include = Inclusion.NON_DEFAULT)
public class DomainParameter {

	private static final long serialVersionUID = 1L;
	
	/**
	 * @uml.property  name="uuid"
	 */
	private String uuid;

	/**
	 * @uml.property  name="ns"
	 */
	private String ns;
	
	/**
	 * @uml.property  name="name"
	 */
	private String name;
	
	/**
	 * @uml.property  name="lowerEnc"
	 */
	private String lowerEnc;
	
	/**
	 * @uml.property  name="upperEnc"
	 */
	private String upperEnc;
	
	/**
	 * @uml.property  name="binNumEnc"
	 */
	private String binNumEnc;

	/**
	 * @param ns
	 * @uml.property  name="ns"
	 */
	public void setNs(String ns) {
		this.ns = ns;
	}

	/**
	 * @return
	 * @uml.property  name="ns"
	 */
	public String getNs() {
		return ns;
	}

	/**
	 * @param name
	 * @uml.property  name="name"
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return
	 * @uml.property  name="name"
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param lowerEnc
	 * @uml.property  name="lowerEnc"
	 */
	public void setLowerEnc(String lowerEnc) {
		this.lowerEnc = lowerEnc;
	}

	/**
	 * @return
	 * @uml.property  name="lowerEnc"
	 */
	public String getLowerEnc() {
		return lowerEnc;
	}

	/**
	 * @param upperEnc
	 * @uml.property  name="upperEnc"
	 */
	public void setUpperEnc(String upperEnc) {
		this.upperEnc = upperEnc;
	}

	/**
	 * @return
	 * @uml.property  name="upperEnc"
	 */
	public String getUpperEnc() {
		return upperEnc;
	}

	/**
	 * @param binNumEnc
	 * @uml.property  name="binNumEnc"
	 */
	public void setBinNumEnc(String binNumEnc) {
		this.binNumEnc = binNumEnc;
	}

	/**
	 * @return
	 * @uml.property  name="binNumEnc"
	 */
	public String getBinNumEnc() {
		return binNumEnc;
	}

	/**
	 * @param uuid
	 * @uml.property  name="uuid"
	 */
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	/**
	 * @return
	 * @uml.property  name="uuid"
	 */
	public String getUuid() {
		return uuid;
	}
	
	public <T extends Number> T parseLow(Class<T> number)
	{
		return parseNumber(lowerEnc,number);
	}

	@SuppressWarnings("unchecked")
	public static <T extends Number> T parseNumber(String val,Class<T> number)
	{
		if(number.equals(Double.class) || number.equals(Float.class))
			return (T)new Double(val);
		return  (T) new Long(val);
	}

	
	public <T extends Number> T parseHigh(Class<T>  number)
	{
		return parseNumber(upperEnc,number);
	}
	
	public void reset()
	{
		setNs(null);
		setUuid(null);
		setName(null);
	}

}
